﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Infrastructure;
using CodeFirstDomain.IService;
using Framework.Infrastructure.IoC;
using CodeFirstDomain.Service;

namespace CodeFirstTest
{
    
    class MongoDBContext : IDisposable
    {

        public MongoDBContext()
        {
        }
        #region IDisposable Members

        public void Dispose()
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    class Program
    {
        static void Main(string[] args)
        {

            ////MongoDB服务器连接串
            //string connectionString = "mongodb://127.0.0.1";
            //MongoServer server = MongoServer.Create(connectionString);
            ////连接到 mongodb_c_demo 数据库
            //MongoDatabase db = server.GetDatabase("mongodb_c_demo");
            ////获取集合 fruit
            //MongoCollection collection = db.GetCollection("fruit");
            ////创建对象 fruit_1
            //BsonDocument fruit_1 = new BsonDocument
            //{
            //  { "name", "apple" },
            //  { "color", "red" }
            //};
            ////创建对象 fruit_2
            //BsonDocument fruit_2 = new BsonDocument
            //{
            //  { "name", "banana" },
            //  { "color", "yellow" }
            //};

            ////将对象 fruit_1 放到集合 fruit 中
            //collection.Insert(fruit_1);
            ////将对象 fruit_2 放到集合 fruit 中
            //collection.Insert(fruit_2);
            ////以上代码完成的就是向fruit表中插入2条数据，用mysql的语法解释即
            ////insert into mongodb_c_demo.fruit (name, color) 
            ////values ('apple', 'red'), ('banana', 'yellow');
            try
            {
                var directService = IoCFactory.Resolve<DirectService>();
                directService.Test();
                using (IAppService service = IoCFactory.Resolve<IAppService>())
                {
                    service.Test();
                }
                //using (AppWcfService.Service1Client service = new AppWcfService.Service1Client())
                //{

                //    var data = service.GetData(1);
                //    Console.Write(data);
                //    var data2 = service.GetData(2);
                //    Console.Write(data2);

                //}


                //AppWcfService2.AppWcfService2Client service2 = new AppWcfService2.AppWcfService2Client();
                
                //service2.DoWork();
            }
            catch (Exception ex)
            {

                Console.Write(ex.Message);
                Console.ReadLine();
            }
            
        }
    }
}
